package com.sword.invoice;

import com.sword.common.strategy.ISCommonStrategy;
import com.sword.invoice.bean.enums.InvoiceChannelEnum;

import java.util.HashMap;

/**
 * @description: 开票管理
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/17
 **/
public class InvoiceManager<T> {
    /**
     * 开票设备组件组件
     */
    private volatile static HashMap<String, Object> driverStrategyHashMap = new HashMap<>();

    /**
     * 设备缓存
     * @param invoiceDriverRepository 开票实现设备
     */
    public static void setISInvoiceDriverRepository(ISCommonStrategy invoiceDriverRepository) {
        if (invoiceDriverRepository != null) {
            driverStrategyHashMap.put(invoiceDriverRepository.getChannelCode(),invoiceDriverRepository);
        }
    }


    public static <T> T getISInvoiceDriverRepository(InvoiceChannelEnum channelEnum, Class<T> clazz) {
        /*if (driverStrategyHashMap == null || driverStrategyHashMap.size()<1) {
            synchronized (SaManager.class) {
                if (saTokenDao == null) {
                    setSaTokenDaoMethod(new SaTokenDaoDefaultImpl());
                }
            }
        }*/

        return (T)driverStrategyHashMap.get(channelEnum.getCode());
    }
}
